package com.angel.domain.angeluser.valueobjects;

import com.angel.infrastructure.tool.IdWorker;
import lombok.Getter;


/*
 * 更新关注微信公众号： 为了offer
 * @author parkin
 * @description  天使用户id
 * @date 2021/11/13
 */

public class AngelUserId {
    // 采用生成的编号(暂时使用雪花算法)-不自增
    @Getter
    private Long id;

    private static IdWorker idWorker;

    static {
        idWorker = new IdWorker();
    }

    public AngelUserId() {
        this.id = generate();
    }

    private AngelUserId(Long angelUserId) {
        this.id = angelUserId;
    }

    public static final AngelUserId toAngelUserId(long angelUserId) {
        return new AngelUserId(angelUserId);
    }

    private long generate() {
        return idWorker.nextId();
    }
}
